package o;

import androidx.annotation.Nullable;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Renderer;

final class aba implements ana {
    private final anm ˊ;
    @Nullable
    private Renderer ˋ;
    private final b ˏ;
    @Nullable
    private ana ॱ;

    public interface b {
        void ॱ(abq o_abq);
    }

    public aba(b bVar, ams o_ams) {
        this.ˏ = bVar;
        this.ˊ = new anm(o_ams);
    }

    public void ˏ() {
        this.ˊ.ˎ();
    }

    public void ˎ() {
        this.ˊ.ˊ();
    }

    public void ˋ(long j) {
        this.ˊ.ˊ(j);
    }

    public void ˎ(Renderer renderer) throws ExoPlaybackException {
        ana ˋ = renderer.ˋ();
        if (ˋ != null && ˋ != this.ॱ) {
            if (this.ॱ != null) {
                throw ExoPlaybackException.ˏ(new IllegalStateException("Multiple renderer media clocks enabled."));
            }
            this.ॱ = ˋ;
            this.ˋ = renderer;
            this.ॱ.ॱ(this.ˊ.e_());
            ᐝ();
        }
    }

    public void ˋ(Renderer renderer) {
        if (renderer == this.ˋ) {
            this.ॱ = null;
            this.ˋ = null;
        }
    }

    public long ˊ() {
        if (!ॱॱ()) {
            return this.ˊ.ॱ();
        }
        ᐝ();
        return this.ॱ.ॱ();
    }

    public long ॱ() {
        if (ॱॱ()) {
            return this.ॱ.ॱ();
        }
        return this.ˊ.ॱ();
    }

    public abq ॱ(abq o_abq) {
        if (this.ॱ != null) {
            o_abq = this.ॱ.ॱ(o_abq);
        }
        this.ˊ.ॱ(o_abq);
        this.ˏ.ॱ(o_abq);
        return o_abq;
    }

    public abq e_() {
        if (this.ॱ != null) {
            return this.ॱ.e_();
        }
        return this.ˊ.e_();
    }

    private void ᐝ() {
        this.ˊ.ˊ(this.ॱ.ॱ());
        abq e_ = this.ॱ.e_();
        if (!e_.equals(this.ˊ.e_())) {
            this.ˊ.ॱ(e_);
            this.ˏ.ॱ(e_);
        }
    }

    private boolean ॱॱ() {
        return (this.ˋ == null || this.ˋ.ʽॱ() || (!this.ˋ.ˈ() && this.ˋ.ᐝ())) ? false : true;
    }
}
